package com.site.action.backend.frame;

import java.util.List;

import javax.annotation.Resource;

import com.site.dto.backend.system.ResourseBizBean;
import com.site.service.backend.system.MenuService;
import com.site.util.base.action.BackendBaseAction;

/**
 * 主框架菜单Action
 * @author 
 *
 */
public class FrameMenuAction extends BackendBaseAction {

	private static final long serialVersionUID = 1L;
	
	private MenuService menuService;
	/*
	 * 用户菜单
	 */
	private List<ResourseBizBean> resourseBizBeanList;

	/**
	 * top
	 * @return
	 */
	public String getTopMenu() {
		log.info("后台 top 加载 - 开始");
		if(this.getCurrentUser() == null){
			return LOGIN;
		}
		log.info("后台 top 加载 - 结束");
		return "top";
	}
	/**
	 * left
	 * @return
	 */
	public String getLeftMenu() {
		log.info("后台 left 加载 - 开始");
		if(this.getCurrentUser() == null){
			return LOGIN;
		}
		// 根据用户获得相应的角色菜单
		// 缓存
		if(null == resourseBizBeanList){
			resourseBizBeanList = menuService.getUserMenu(this.currentUser.getId(), request);
		}
		// 没有缓存
		if(resourseBizBeanList == null || resourseBizBeanList.size() <= 0){
			resourseBizBeanList = menuService.getUserMenu(this.currentUser.getId());
		}
		log.info("后台 left 加载 - 结束");
		return "left";
	}
	
	/**
	 * center
	 * @return
	 */
	public String getCenterMenu(){
		return "center";
	}
	
	/**
	 * right
	 * @return
	 */
	public String getRightMenu(){
		return "right";
	}
	
	public MenuService getMenuService() {
		return menuService;
	}
	@Resource
	public void setMenuService(MenuService menuService) {
		this.menuService = menuService;
	}
	public void setResourseBizBeanList(List<ResourseBizBean> resourseBizBeanList) {
		this.resourseBizBeanList = resourseBizBeanList;
	}
	public List<ResourseBizBean> getResourseBizBeanList() {
		return resourseBizBeanList;
	}
	
}
